const { mock } = require('mockjs')

const List = []
for (let i = 0; i < 5; i++) {
  List.push(
    mock({
      id: '@id',
      name: '@cword(4, 8)',
      typeKey: '@word(3, 5)',
      parentId: '@increment',
      isLeaf: '@boolean',
      'children|5': [
        {
          id: '@id',
          name: '@cword(4, 8)',
          typeGroupKey: '@word(3, 5)',
          typeKey: '@word(2, 4)',
          parentId: '@increment',
          isLeaf: '@boolean',
        },
      ],
    })
  )
}
module.exports = [
  {
    url: '/tree/getTreeList',
    type: 'post',
    response(config) {
      if (!config.body) {
        return {
          code: 200,
          msg: 'success',
          data: mock({
            'data|5': [
              {
                id: '@id',
                name: '@cword(4, 8)',
                typeKey: '@word(3, 5)',
                parentId: '@increment',
                isLeaf: '@boolean',
                'children|5': [
                  {
                    id: '@id',
                    name: '@cword(4, 8)',
                    typeGroupKey: '@word(3, 5)',
                    typeKey: '@word(2, 4)',
                    parentId: '@increment',
                    isLeaf: '@boolean',
                  },
                ],
              },
            ],
          }).data,
        }
      }
      return {
        code: 200,
        msg: 'success',
        data: List,
      }
    },
  },
]
